package edu.ucdavis.gwt.gis.client.toolbar.button;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.Image;

import edu.ucdavis.gwt.gis.client.DataManager;
import edu.ucdavis.gwt.gis.client.print.PrintPage;
import edu.ucdavis.gwt.gis.client.resources.GadgetResources;
import edu.ucdavis.gwt.gis.client.toolbar.Toolbar;

public class PrintButton extends ToolbarItem {
	
	private String text = "Print Map";

	public void setText(String s) {
		text = s;
	}

	@Override
	public Image getIcon() {
		return new Image(GadgetResources.INSTANCE.printer());
	}

	@Override
	public void onAdd(Toolbar toolbar) {}

	@Override
	public void onClick(ClickEvent event) {
		PrintPage page = DataManager.INSTANCE.getPrintPage();
		if( page != null ) {
			page.onPrintIconClick(DataManager.INSTANCE.getMap());
		}
	}

	@Override
	public String getText() {
		return text;
	}

}
